package game.module.sss.logic;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.common.PrimitiveTypeConstants;
import game.module.sss.SssConstants;
import game.module.sss.bean.SssEnSortCardType;
import game.module.sss.bean.TagAnalyseData;

public class SssAlgorithm {

	private static Logger logger = LoggerFactory.getLogger(SssAlgorithm.class);

	static class SingletonHolder {
		static SssAlgorithm instance = new SssAlgorithm();
	}

	public static SssAlgorithm getInstance() {
		return SingletonHolder.instance;
	}
	
	public byte[] btCardSpecialData = new byte[13];

	// 获取数值
	public byte GetCardValue(byte bCardData) {
		return (byte) (bCardData & SssConstants.LOGIC_MASK_VALUE);
	} // 十六进制前面四位表示牌的数值

	// 获取花色
	public byte GetCardColor(byte bCardData) {
		return (byte) ((bCardData & SssConstants.LOGIC_MASK_COLOR) >> 4);
	} // 十六进制后面四位表示牌的花色

	// 逻辑数值
	public byte GetCardLogicValue(byte bCardData) {
		// 扑克属性
		byte bCardValue = GetCardValue(bCardData);

		// 转换数值
		return (byte) ((bCardValue == 1) ? (bCardValue + 13) : bCardValue);
	}

	// 排列扑克
	public void SortCardList(byte bCardData[], byte bCardCount, SssEnSortCardType SortCardType) {
		assert (bCardCount >= 1 && bCardCount <= 13);
		if (bCardCount < 1 || bCardCount > 13)
			return;

		// 转换数值
		byte[] bLogicVolue = new byte[13];
		for (byte i = 0; i < bCardCount; i++)
			bLogicVolue[i] = GetCardLogicValue(bCardData[i]);

		if (SssEnSortCardType.enDescend == SortCardType) {
			// 排序操作
			boolean bSorted = true;
			byte bTempData, bLast = (byte) (bCardCount - 1);
			byte m_bCardCount = 1;
			do {
				bSorted = true;
				for (byte i = 0; i < bLast; i++) {
					if ((bLogicVolue[i] < bLogicVolue[i + 1])
							|| ((bLogicVolue[i] == bLogicVolue[i + 1]) && (bCardData[i] < bCardData[i + 1]))) {
						// 交换位置
						bTempData = bCardData[i];
						bCardData[i] = bCardData[i + 1];
						bCardData[i + 1] = bTempData;
						bTempData = bLogicVolue[i];
						bLogicVolue[i] = bLogicVolue[i + 1];
						bLogicVolue[i + 1] = bTempData;
						bSorted = false;
					}
				}
				bLast--;
			} while (bSorted == false);
		} else if (SssEnSortCardType.enAscend == SortCardType) {
			// 排序操作
			boolean bSorted = true;
			byte bTempData, bLast = (byte) (bCardCount - 1);
			byte m_bCardCount = 1;
			do {
				bSorted = true;
				for (byte i = 0; i < bLast; i++) {
					if ((bLogicVolue[i] > bLogicVolue[i + 1])
							|| ((bLogicVolue[i] == bLogicVolue[i + 1]) && (bCardData[i] > bCardData[i + 1]))) {
						// 交换位置
						bTempData = bCardData[i];
						bCardData[i] = bCardData[i + 1];
						bCardData[i + 1] = bTempData;
						bTempData = bLogicVolue[i];
						bLogicVolue[i] = bLogicVolue[i + 1];
						bLogicVolue[i + 1] = bTempData;
						bSorted = false;
					}
				}
				bLast--;
			} while (bSorted == false);
		} else if (SssEnSortCardType.enColor == SortCardType) {
			// 排序操作
			boolean bSorted = true;
			byte bTempData, bLast = (byte) (bCardCount - 1);
			byte m_bCardCount = 1;
			byte[] bColor = new byte[13];
			for (byte i = 0; i < bCardCount; i++)
				bColor[i] = GetCardColor(bCardData[i]);
			do {
				bSorted = true;
				for (byte i = 0; i < bLast; i++) {
					if ((bColor[i] < bColor[i + 1]) || ((bColor[i] == bColor[i + 1])
							&& (GetCardLogicValue(bCardData[i]) < GetCardLogicValue(bCardData[i + 1])))) {
						// 交换位置
						bTempData = bCardData[i];
						bCardData[i] = bCardData[i + 1];
						bCardData[i + 1] = bTempData;
						bTempData = bColor[i];
						bColor[i] = bColor[i + 1];
						bColor[i + 1] = bTempData;
						bSorted = false;
					}
				}
				bLast--;
			} while (bSorted == false);
		} else if (SssEnSortCardType.natualDecend == SortCardType) {
			for (byte i = 0; i < bCardCount; i++)
				bLogicVolue[i] = GetCardValue(bCardData[i]);
			// 排序操作
			boolean bSorted = true;
			byte bTempData, bLast = (byte) (bCardCount - 1);
			byte m_bCardCount = 1;
			do {
				bSorted = true;
				for (byte i = 0; i < bLast; i++) {
					if ((bLogicVolue[i] < bLogicVolue[i + 1])
							|| ((bLogicVolue[i] == bLogicVolue[i + 1]) && (bCardData[i] < bCardData[i + 1]))) {
						// 交换位置
						bTempData = bCardData[i];
						bCardData[i] = bCardData[i + 1];
						bCardData[i + 1] = bTempData;
						bTempData = bLogicVolue[i];
						bLogicVolue[i] = bLogicVolue[i + 1];
						bLogicVolue[i + 1] = bTempData;
						bSorted = false;
					}
				}
				bLast--;
			} while (bSorted == false);
		}
		return;
	}

	// 分析扑克
	public void AnalyseCard(byte bCardDataList[], byte bCardCount, TagAnalyseData AnalyseData) {
		// 排列扑克
		byte[] bCardData = Arrays.copyOf(bCardDataList, bCardCount);
		SortCardList(bCardData, bCardCount, SssEnSortCardType.enDescend);

		// 变量定义
		byte bSameCount = 1, bCardValueTemp = 0, bSameColorCount = 1, bFirstCardIndex = 0; // 记录下标

		byte bLogicValue = GetCardLogicValue(bCardData[0]);
		byte bCardColor = GetCardColor(bCardData[0]);

		// if(bCardCount!=3 && bCardCount!=5)
		// {
		// #ifdef _DEBUG
		// AfxMessageBox("ok") ;
		// return ;
		// #endif
		// }

		assert (3 == bCardCount || 5 == bCardCount || 13 == bCardCount);

		// 设置结果
		AnalyseData.resetData();

		// 扑克分析
		for (byte i = 1; i < bCardCount; i++) {
			// 获取扑克
			bCardValueTemp = GetCardLogicValue(bCardData[i]);
			if (bCardValueTemp == bLogicValue)
				bSameCount++;

			// 保存结果
			if ((bCardValueTemp != bLogicValue) || (i == (bCardCount - 1))) {
				switch (bSameCount) {
				case 1: // 一张
					break;
				case 2: // 两张
				{
					AnalyseData.bTwoFirst[AnalyseData.bTwoCount] = bFirstCardIndex;
					AnalyseData.bTwoCount++;
					break;
				}
				case 3: // 三张
				{
					AnalyseData.bThreeFirst[AnalyseData.bThreeCount] = bFirstCardIndex;
					AnalyseData.bThreeCount++;
					break;
				}
				case 4: // 四张
				{
					AnalyseData.bFourFirst[AnalyseData.bFourCount] = bFirstCardIndex;
					AnalyseData.bFourCount++;
					break;
				}
				case 5: // 五张
				{
					AnalyseData.bFiveCount++;
					break;
				}
				default:
					// CString str ;
					// str.Format("AnalyseCard：错误扑克！: %d" , bSameCount) ;
					// #ifdef _DEBUG
					// AfxMessageBox(str) ;
					// #endif
					break;
				}
			}

			// 设置变量
			if (bCardValueTemp != bLogicValue) {
				if (bSameCount == 1) {
					if (i != bCardCount - 1) {
						AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
						AnalyseData.bOneCount++;
					} else {
						AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
						AnalyseData.bOneCount++;
						AnalyseData.bOneFirst[AnalyseData.bOneCount] = i;
						AnalyseData.bOneCount++;
					}
				} else {
					if (i == bCardCount - 1) {
						AnalyseData.bOneFirst[AnalyseData.bOneCount] = i;
						AnalyseData.bOneCount++;
					}
				}
				bSameCount = 1;
				bLogicValue = bCardValueTemp;
				bFirstCardIndex = i;

			}
			if (GetCardColor(bCardData[i]) != bCardColor)
				bSameColorCount = 1;
			else
				++bSameColorCount;
		}

		// 是否同花
		AnalyseData.bStraight = (bCardCount == bSameColorCount) ? true : false;

		return;
	}

	// 删除扑克
	public boolean RemoveCard(byte bRemoveCard[], byte bRemoveCount, byte bCardData[], byte bCardCount) {
		// 检验数据
		assert (bRemoveCount <= bCardCount);

		// 定义变量
		byte bDeleteCount = 0;
		if (bCardCount > SssConstants.HAND_CARD_COUNT)
			return false;
		byte[] bTempCardData = Arrays.copyOf(bCardData, bCardCount);
		// 置零扑克
		for (byte i = 0; i < bRemoveCount; i++) {
			for (byte j = 0; j < bCardCount; j++) {
				if (bRemoveCard[i] == bTempCardData[j]) {
					bDeleteCount++;
					bTempCardData[j] = 0;
					break;
				}
			}
		}
		if (bDeleteCount != bRemoveCount)
			return false;

		// 清理扑克
		byte bCardPos = 0;
		for (byte i = 0; i < bCardCount; i++) {
			if (bTempCardData[i] != 0)
				bCardData[bCardPos++] = bTempCardData[i];
		}

		return true;
	}

	// 获取类型
	public byte GetCardType(byte bCardData[], byte bCardCount, byte btSpecialCard[]) {
		// 数据校验
		assert (bCardCount == 3 || bCardCount == 5 || 13 == bCardCount);
		if (bCardCount != 3 && bCardCount != 5 && bCardCount != 13)
			return SssConstants.CT_INVALID;

		TagAnalyseData AnalyseData = new TagAnalyseData();
		// assert(3==bCardCount || 5==bCardCount) ;

		AnalyseCard(bCardData, bCardCount, AnalyseData);

		// 开始分析
		switch (bCardCount) {
		case 3: // 三条类型
		{
			// 单牌类型
			if (3 == AnalyseData.bOneCount)
				return SssConstants.CT_SINGLE;

			// 对带一张
			if (1 == AnalyseData.bTwoCount && 1 == AnalyseData.bOneCount)
				return SssConstants.CT_ONE_DOUBLE;

			// 三张牌型
			if (1 == AnalyseData.bThreeCount)
				return SssConstants.CT_THREE;

			// 错误类型
			return SssConstants.CT_INVALID;
		}
		case 5: // 五张牌型
		{
			boolean bFlushNoA = false, bFlushFirstA = false, bFlushBackA = false;

			// A连在后
			if (14 == GetCardLogicValue(bCardData[0]) && 10 == GetCardLogicValue(bCardData[4]))
				bFlushBackA = true;
			else
				bFlushNoA = true;
			for (byte i = 0; i < 4; ++i)
				if (1 != GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1])) {
					bFlushBackA = false;
					bFlushNoA = false;
				}
			// A连在前
			if (false == bFlushBackA && false == bFlushNoA && 14 == GetCardLogicValue(bCardData[0])) {
				bFlushFirstA = true;
				for (byte i = 1; i < 4; ++i)
					if (1 != GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]))
						bFlushFirstA = false;
				if (2 != GetCardLogicValue(bCardData[4]))
					bFlushFirstA = false;
			}

			// 同花五牌
			if (false == bFlushBackA && false == bFlushNoA && false == bFlushFirstA) {
				if (true == AnalyseData.bStraight)
					return SssConstants.CT_FIVE_FLUSH;
			} else if (true == bFlushNoA) {
				// 杂顺类型
				if (false == AnalyseData.bStraight)
					return SssConstants.CT_FIVE_MIXED_FLUSH_NO_A;
				// 同花顺牌
				else
					return SssConstants.CT_FIVE_STRAIGHT_FLUSH_NO_A;
			} else if (true == bFlushFirstA) {
				// 杂顺类型
				if (false == AnalyseData.bStraight)
					return SssConstants.CT_FIVE_MIXED_FLUSH_FIRST_A;
				// 同花顺牌
				else
					return SssConstants.CT_FIVE_STRAIGHT_FLUSH_FIRST_A;
			} else if (true == bFlushBackA) {
				// 杂顺类型
				if (false == AnalyseData.bStraight)
					return SssConstants.CT_FIVE_MIXED_FLUSH_BACK_A;
				// 同花顺牌
				else
					return SssConstants.CT_FIVE_STRAIGHT_FLUSH_BACK_A;
			}

			// 四带单张
			if (1 == AnalyseData.bFourCount && 1 == AnalyseData.bOneCount)
				return SssConstants.CT_FIVE_FOUR_ONE;
			
			// 五同
			if (1 == AnalyseData.bFiveCount)
				return SssConstants.CT_FIVE_SAME;
			
			// 三条一对
			if (1 == AnalyseData.bThreeCount && 1 == AnalyseData.bTwoCount)
				return SssConstants.CT_FIVE_THREE_DEOUBLE;

			// 三条带单
			if (1 == AnalyseData.bThreeCount && 2 == AnalyseData.bOneCount)
				return SssConstants.CT_THREE;

			// 两对牌型
			if (2 == AnalyseData.bTwoCount && 1 == AnalyseData.bOneCount)
				return SssConstants.CT_FIVE_TWO_DOUBLE;

			// 只有一对
			if (1 == AnalyseData.bTwoCount && 3 == AnalyseData.bOneCount)
				return SssConstants.CT_ONE_DOUBLE;

			// 单牌类型
			if (5 == AnalyseData.bOneCount && false == AnalyseData.bStraight)
				return SssConstants.CT_SINGLE;

			// 错误类型
			return SssConstants.CT_INVALID;
		}
		case 13:// 13张特殊牌型
		{
			boolean TwelveKing = false;
			// 同花十三水
			if (13 == AnalyseData.bOneCount && true == AnalyseData.bStraight)
				return SssConstants.CT_THIRTEEN_FLUSH;
			// 十三水
			if (13 == AnalyseData.bOneCount)
				return SssConstants.CT_THIRTEEN;
			// 十二皇族
			TwelveKing = true;
			for (int i = 0; i < 13; i++) {
				if (GetCardLogicValue(bCardData[i]) < 11) {
					TwelveKing = false;
					break;
				}
			}
			if (TwelveKing) {
				return SssConstants.CT_TWELVE_KING;
			}
			// 三同花顺 TODO A当做最小算
			byte[] btCardData = new byte[13];
			byte[] RbtCardData = new byte[13];
			// CopyMemory(btCardData,bCardData,sizeof(btCardData));
			System.arraycopy(bCardData, 0, btCardData, 0, btCardData.length);
			SortCardList(btCardData, (byte) 13, SssEnSortCardType.enDescend);
			boolean StraightFlush1 = false;
			boolean StraightFlush2 = false;
			boolean StraightFlush3 = false;
			byte StraightFlush = 1;
			byte Number = 0;
			byte Count1 = 0;
			byte Count2 = 0;
			byte Count3 = 0;
			byte FCardData = GetCardLogicValue(btCardData[0]);
			byte SColor = GetCardColor(btCardData[0]);
			RbtCardData[Number++] = btCardData[0];
			for (int i = 1; i < 13; i++) {
				if (FCardData == GetCardLogicValue(btCardData[i]) + 1 && SColor == GetCardColor(btCardData[i])) {
					StraightFlush++;
					FCardData = GetCardLogicValue(btCardData[i]);
					RbtCardData[Number++] = btCardData[i];
				}
				if (FCardData != GetCardLogicValue(btCardData[i]) + 1 && FCardData != GetCardLogicValue(btCardData[i])) {
					if (3 == StraightFlush) {
						StraightFlush1 = true;
						Count1 = 3;
						RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) 13);
						Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
					}
					break;
				}
				if (5 == StraightFlush) {
					StraightFlush1 = true;
					Count1 = 5;
					RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) 13);
					Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
					break;
				}

			}
			if (StraightFlush1) {
				StraightFlush = 1;
				Number = 0;
				FCardData = GetCardLogicValue(btCardData[0]);
				SColor = GetCardColor(btCardData[0]);
				RbtCardData[Number++] = btCardData[0];
				for (int i = 1; i < 13 - Count1 + 1; i++) {
					if (FCardData == GetCardLogicValue(btCardData[i]) + 1 && SColor == GetCardColor(btCardData[i])) {
						StraightFlush++;
						FCardData = GetCardLogicValue(btCardData[i]);
						RbtCardData[Number++] = btCardData[i];
					}
					if (FCardData != GetCardLogicValue(btCardData[i]) + 1
							&& FCardData != GetCardLogicValue(btCardData[i])) {
						if (3 == StraightFlush) {
							StraightFlush1 = true;
							Count2 = 3;
							RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1));
							Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						}
						break;
					}
					if (5 == StraightFlush) {
						StraightFlush2 = true;
						Count2 = 5;
						RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) (13 - Count1));
						Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						break;
					}
				}
			}
			if (StraightFlush2) {
				StraightFlush = 1;
				Number = 0;
				FCardData = GetCardLogicValue(btCardData[0]);
				SColor = GetCardColor(btCardData[0]);
				RbtCardData[Number++] = btCardData[0];
				for (int i = 1; i < 13 - Count1 - Count2 + 1; i++) {
					if (FCardData == GetCardLogicValue(btCardData[i]) + 1 && SColor == GetCardColor(btCardData[i])) {
						StraightFlush++;
						FCardData = GetCardLogicValue(btCardData[i]);
						RbtCardData[Number++] = btCardData[i];
					}
					if (FCardData != GetCardLogicValue(btCardData[i]) + 1
							&& FCardData != GetCardLogicValue(btCardData[i])) {
						if (3 == StraightFlush) {
							StraightFlush3 = true;
							Count3 = 3;
							RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1 - Count2));
							Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						}
						break;
					}
					if (5 == StraightFlush) {
						StraightFlush3 = true;
						Count3 = 5;
						RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) (13 - Count1 - Count2));
						Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						break;
					}
				}
			}
			if (StraightFlush1 && StraightFlush2 && StraightFlush3 && Count1 + Count2 + Count3 == 13) {
				return SssConstants.CT_THREE_STRAIGHTFLUSH;
			}
			// 三炸弹
			if (3 == AnalyseData.bFourCount) {
				return SssConstants.CT_THREE_BOMB;
			}
			// 全大
			boolean AllBig = true;
			for (int i = 0; i < 13; i++) {
				if (GetCardLogicValue(bCardData[i]) < 8) {
					AllBig = false;
					break;
				}
			}
			if (AllBig) {
				return SssConstants.CT_ALL_BIG;
			}
			// 全小
			boolean AllSmall = true;
			for (int i = 0; i < 13; i++) {
				if (GetCardLogicValue(bCardData[i]) > 8) {
					AllSmall = false;
					break;
				}
			}
			if (AllSmall) {
				return SssConstants.CT_ALL_SMALL;
			}
			// 凑一色，花色为方块+红心  或者梅花+黑桃
			byte Flush = 1;
//			SColor = GetCardColor(bCardData[0]);
//			for (int i = 1; i < 13; i++) {
//				if (SColor == GetCardColor(bCardData[i])) {
//					Flush++;
//				} else {
//					break;
//				}
//			}
//			if (13 == Flush) {
//				return SssConstants.CT_SAME_COLOR;
//			}
			Set<Byte> colorSet = new HashSet<>();
			for (int i = 1; i < 13; i++) {
				SColor = GetCardColor(bCardData[i]);
				colorSet.add(SColor);
			}
			if (colorSet.size() == 2) {
				Iterator<Byte> colorIte = colorSet.iterator();
				byte color1 = colorIte.next();
				byte color2 = colorIte.next();
				if (color1 == 0 && color2 == 2 || color1 == 2 && color2 == 0 || color1 == 1 && color2 == 3
						|| color1 == 3 && color2 == 1) {
					return SssConstants.CT_SAME_COLOR;
				}
			} else if (colorSet.size() == 1) {
				return SssConstants.CT_SAME_COLOR;
			}
			// 四套冲三
			if (4 == AnalyseData.bThreeCount) {
				return SssConstants.CT_FOUR_THREESAME;
			}
			// 五对冲三
			if ((5 == AnalyseData.bTwoCount && 1 == AnalyseData.bThreeCount)
					|| (3 == AnalyseData.bTwoCount && 1 == AnalyseData.bFourCount && 1 == AnalyseData.bThreeCount)
					|| (1 == AnalyseData.bTwoCount && 2 == AnalyseData.bFourCount && 1 == AnalyseData.bThreeCount)) {
				return SssConstants.CT_FIVEPAIR_THREE;
			}
			// 六对半
			if (6 == AnalyseData.bTwoCount || (4 == AnalyseData.bTwoCount && 1 == AnalyseData.bFourCount)
					|| (2 == AnalyseData.bTwoCount && 2 == AnalyseData.bFourCount) || (3 == AnalyseData.bFourCount)) {
				return SssConstants.CT_SIXPAIR;
			}
			// 三同花
			boolean Flush1 = false;
			boolean Flush2 = false;
			boolean Flush3 = false;
			Flush = 1;
			Count1 = 0;
			Count2 = 0;
			Count3 = 0;
			Number = 0;
			Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
			// CopyMemory(btCardData,bCardData,sizeof(btCardData));
			System.arraycopy(bCardData, 0, btCardData, 0, btCardData.length);
			RbtCardData[Number++] = btCardData[0];
			SColor = GetCardColor(btCardData[0]);
			for (int i = 1; i < 13; i++) {
				if (SColor == GetCardColor(btCardData[i])) {
					Flush++;
					RbtCardData[Number++] = btCardData[i];
				}
				if (3 == Flush && i == 12) {
					Flush1 = true;
					Count1 = 3;
					// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count1);
					System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count1);
					RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) 13);
					Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
					break;
				}
				if (5 == Flush) {
					Flush1 = true;
					Count1 = 5;
					// CopyMemory(&btSpecialCard[5],RbtCardData,sizeof(byte)*Count1);
					System.arraycopy(RbtCardData, 0, btSpecialCard, 5, Count1);
					RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) 13);
					Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
					break;
				}
			}
			if (Flush1) {
				Flush = 1;
				Number = 0;
				RbtCardData[Number++] = btCardData[0];
				SColor = GetCardColor(btCardData[0]);
				for (int i = 1; i < 13 - Count1; i++) {
					if (SColor == GetCardColor(btCardData[i])) {
						Flush++;
						RbtCardData[Number++] = btCardData[i];
					}
					if (3 == Flush && i == 13 - Count1 - 1 && Count1 != 3) {
						Flush2 = true;
						Count2 = 3;
						// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count2);
						System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count2);
						RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1));
						Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						break;
					}
					if (5 == Flush) {
						Flush2 = true;
						Count2 = 5;
						if (Count1 == 5) {
							// CopyMemory(&btSpecialCard[0],RbtCardData,sizeof(byte)*Count2);
							System.arraycopy(RbtCardData, 0, btSpecialCard, 0, Count2);
						} else if (Count1 == 3) {
							// CopyMemory(&btSpecialCard[5],RbtCardData,sizeof(byte)*Count2);
							System.arraycopy(RbtCardData, 0, btSpecialCard, 5, Count2);
						}

						RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) (13 - Count1));
						Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						break;
					}
				}
			}
			if (Flush2) {
				Flush = 1;
				Number = 0;
				RbtCardData[Number++] = btCardData[0];
				SColor = GetCardColor(btCardData[0]);
				for (int i = 1; i < 13 - Count1 - Count2; i++) {
					if (SColor == GetCardColor(btCardData[i])) {
						Flush++;
						RbtCardData[Number++] = btCardData[i];
					}
					if (3 == Flush && i == 13 - Count1 - Count2 - 1 && Count1 != 3 && Count2 != 3) {
						Flush3 = true;
						Count3 = 3;
						// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count3);
						System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count3);
						RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1 - Count2));
						Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						break;
					}
					if (5 == Flush) {
						Flush3 = true;
						Count3 = 5;
						// CopyMemory(&btSpecialCard[0],RbtCardData,sizeof(byte)*Count3);
						System.arraycopy(RbtCardData, 0, btSpecialCard, 0, Count3);
						RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) (13 - Count1 - Count2));
						Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						break;
					}
				}
			}
			if (Flush1 && Flush2 && Flush3 && Count1 + Count2 + Count3 == 13) {
				return SssConstants.CT_THREE_FLUSH;
			}
			// 三顺子
			int nCount = 0;
			while (nCount < 4) {
				nCount++;
				boolean Straight1 = false;
				boolean Straight2 = false;
				boolean Straight3 = false;
				byte Straight = 1;
				Count1 = 0;
				Count2 = 0;
				Count3 = 0;
				Number = 0;
				Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
				// CopyMemory(btCardData,bCardData,sizeof(btCardData));
				System.arraycopy(bCardData, 0, btCardData, 0, btCardData.length);
				SortCardList(btCardData, (byte) 13, SssEnSortCardType.enDescend);
				RbtCardData[Number++] = btCardData[0];
				FCardData = GetCardLogicValue(btCardData[0]);
				for (int i = 1; i < 13; i++) {
					if (FCardData == GetCardLogicValue(btCardData[i]) + 1
							|| (FCardData == 14 && GetCardLogicValue(btCardData[i]) == 5)
							|| (FCardData == 14 && GetCardLogicValue(btCardData[i]) == 3)) {
						Straight++;
						RbtCardData[Number++] = btCardData[i];
						FCardData = GetCardLogicValue(btCardData[i]);

					} else if (FCardData != GetCardLogicValue(btCardData[i])) {
						if (3 == Straight) {
							Straight1 = true;
							Count1 = 3;
							// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count1);
							System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count1);
							RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) 13);
							Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
							break;
						}
						Straight = 1;
						Number = 0;
						FCardData = GetCardLogicValue(btCardData[i]);
						RbtCardData[Number++] = btCardData[i];

					}
					if (nCount == 0 || nCount == 1) {
						if (i == 12 && 3 == Straight) {

							Straight1 = true;
							Count1 = 3;
							// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count1);
							System.arraycopy(RbtCardData, 0, btSpecialCard, 0, Count1);
							RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) 13);
							Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
							break;

						}
					} else if (nCount == 2 || nCount == 3) {
						if (3 == Straight) {

							Straight1 = true;
							Count1 = 3;
							// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count1);
							System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count1);
							RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) 13);
							Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
							break;
						}
					}
					if (5 == Straight) {
						Straight1 = true;
						Count1 = 5;
						// CopyMemory(&btSpecialCard[5],RbtCardData,sizeof(byte)*Count1);
						System.arraycopy(RbtCardData, 0, btSpecialCard, 5, Count1);
						RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) 13);
						Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
						break;

					}
				}
				if (Straight1) {
					Straight = 1;
					Number = 0;
					SortCardList(btCardData, (byte) (13 - Count1), SssEnSortCardType.enDescend);
					RbtCardData[Number++] = btCardData[0];
					FCardData = GetCardLogicValue(btCardData[0]);
					for (int i = 1; i < 13 - Count1; i++) {
						if (FCardData == GetCardLogicValue(btCardData[i]) + 1
								|| (FCardData == 14 && GetCardLogicValue(btCardData[i]) == 5)
								|| (FCardData == 14 && GetCardLogicValue(btCardData[i]) == 3)) {
							Straight++;
							RbtCardData[Number++] = btCardData[i];
							FCardData = GetCardLogicValue(btCardData[i]);

						} else if (FCardData != GetCardLogicValue(btCardData[i])) {
							if (3 == Straight && Count1 != 3) {
								Straight2 = true;
								Count2 = 3;
								// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count2);
								System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count2);
								RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1));
								Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
								break;
							}
							Straight = 1;
							Number = 0;
							FCardData = GetCardLogicValue(btCardData[i]);
							RbtCardData[Number++] = btCardData[i];
						}
						if (nCount == 0 || nCount == 2) {
							if (i == 13 - Count1 - 1 && 3 == Straight && Count1 != 3) {
								Straight2 = true;
								Count2 = 3;
								// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count2);
								System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count2);
								RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1));
								Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
								break;

							}
						} else if (nCount == 1 || nCount == 3) {
							if (3 == Straight && Count1 != 3) {
								Straight2 = true;
								Count2 = 3;
								// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count2);
								System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count2);
								RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1));
								Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
								break;

							}
						}
						if (5 == Straight) {
							Straight2 = true;
							Count2 = 5;
							if (Count1 == 5) {
								// CopyMemory(&btSpecialCard[0],RbtCardData,sizeof(byte)*Count2);
								System.arraycopy(RbtCardData, 0, btSpecialCard, 0, Count2);
							} else {
								// CopyMemory(&btSpecialCard[5],RbtCardData,sizeof(byte)*Count2);
								System.arraycopy(RbtCardData, 0, btSpecialCard, 5, Count2);
							}

							RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) (13 - Count1));
							Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
							break;
						}
					}
				}
				if (Straight2) {
					Straight = 1;
					Number = 0;
					SortCardList(btCardData, (byte) (13 - Count1 - Count2), SssEnSortCardType.enDescend);
					RbtCardData[Number++] = btCardData[0];
					FCardData = GetCardLogicValue(btCardData[0]);
					for (int i = 1; i < 13 - Count1 - Count2; i++) {
						if (FCardData == GetCardLogicValue(btCardData[i]) + 1
								|| (FCardData == 14 && GetCardLogicValue(btCardData[i]) == 3)
								|| (FCardData == 14 && GetCardLogicValue(btCardData[i]) == 5)) {
							Straight++;
							RbtCardData[Number++] = btCardData[i];
							FCardData = GetCardLogicValue(btCardData[i]);
						} else if (FCardData != GetCardLogicValue(btCardData[i])) {
							if (3 == Straight && Count1 != 3 && Count2 != 3) {
								Straight3 = true;
								Count3 = 3;
								// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count3);
								System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count3);
								RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1 - Count2));
								Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
								break;
							}
							Straight = 1;
							Number = 0;
							FCardData = GetCardLogicValue(btCardData[i]);
							RbtCardData[Number++] = btCardData[i];
						}
						if (i == 13 - Count1 - Count2 - 1 && 3 == Straight && Count1 != 3 && Count2 != 3) {
							Straight3 = true;
							Count3 = 3;
							// CopyMemory(&btSpecialCard[10],RbtCardData,sizeof(byte)*Count3);
							System.arraycopy(RbtCardData, 0, btSpecialCard, 10, Count3);
							RemoveCard(RbtCardData, (byte) 3, btCardData, (byte) (13 - Count1 - Count2));
							Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
							break;
						}
						if (5 == Straight) {
							Straight3 = true;
							Count3 = 5;
							// CopyMemory(&btSpecialCard[0],RbtCardData,sizeof(byte)*Count3);
							System.arraycopy(RbtCardData, 0, btSpecialCard, 0, Count3);
							RemoveCard(RbtCardData, (byte) 5, btCardData, (byte) (13 - Count1 - Count2));
							Arrays.fill(RbtCardData, PrimitiveTypeConstants.BYTE_ZERO);
							break;
						}
					}
				}
				if (Straight1 && Straight2 && Straight3 && Count1 + Count2 + Count3 == 13) {
					return SssConstants.CT_THREE_STRAIGHT;
				}
			}
		}
		}
		return SssConstants.CT_INVALID;
	}

	/**
	 *  对比扑克,if next > first 返回true
	 * @param bInFirstList
	 * @param bInNextList
	 * @param bFirstCount
	 * @param bNextCount
	 * @param bComperWithOther
	 * @return
	 */
	public boolean CompareCard(byte bInFirstList[], byte bInNextList[], byte bFirstCount, byte bNextCount,
			boolean bComperWithOther,byte firstAConfig) {
		TagAnalyseData FirstAnalyseData = new TagAnalyseData(), NextAnalyseData = new TagAnalyseData();

		// memset(&FirstAnalyseData , 0 , sizeof(tagAnalyseData)) ;
		// memset(&NextAnalyseData , 0 , sizeof(tagAnalyseData)) ;
		FirstAnalyseData.resetData();
		NextAnalyseData.resetData();

		// 排列扑克
		// CopyMemory(bFirstList , bInFirstList , bFirstCount) ;
		// CopyMemory(bNextList , bInNextList , bNextCount) ;
		byte[] bFirstList = Arrays.copyOf(bInFirstList, bFirstCount);
		byte[] bNextList = Arrays.copyOf(bInNextList, bNextCount);
		SortCardList(bFirstList, bFirstCount, SssEnSortCardType.enDescend);
		SortCardList(bNextList, bNextCount, SssEnSortCardType.enDescend);

		assert (3 == bFirstCount || 5 == bFirstCount || 3 == bNextCount || 5 == bNextCount || 13 == bFirstCount
				|| 13 == bNextCount);

		AnalyseCard(bFirstList, bFirstCount, FirstAnalyseData);

		AnalyseCard(bNextList, bNextCount, NextAnalyseData);

		assert (bFirstCount == (FirstAnalyseData.bOneCount + FirstAnalyseData.bTwoCount * 2
				+ FirstAnalyseData.bThreeCount * 3 + FirstAnalyseData.bFourCount * 4
				+ FirstAnalyseData.bFiveCount * 5));
		bNextCount = (byte) (NextAnalyseData.bOneCount + NextAnalyseData.bTwoCount * 2 + NextAnalyseData.bThreeCount * 3
				+ NextAnalyseData.bFourCount * 4 + NextAnalyseData.bFiveCount * 5);
		assert (bNextCount > 0);
		if (bFirstCount != (FirstAnalyseData.bOneCount + FirstAnalyseData.bTwoCount * 2
				+ FirstAnalyseData.bThreeCount * 3 + FirstAnalyseData.bFourCount * 4
				+ FirstAnalyseData.bFiveCount * 5)) {
			// AfxMessageBox("error") ;
			return false;
		}
		if (bNextCount != (NextAnalyseData.bOneCount + NextAnalyseData.bTwoCount * 2 + NextAnalyseData.bThreeCount * 3
				+ NextAnalyseData.bFourCount * 4 + NextAnalyseData.bFiveCount * 5)) {
			// AfxMessageBox("error") ;
			return false;
		}
		// 数据验证
		assert ((bFirstCount == bNextCount) || (bFirstCount != bNextCount
				&& (3 == bFirstCount && 5 == bNextCount || 5 == bFirstCount && 3 == bNextCount)));
		if (!((bFirstCount == bNextCount) || (bFirstCount != bNextCount
				&& (3 == bFirstCount && 5 == bNextCount || 5 == bFirstCount && 3 == bNextCount))))
			return false;

		// 获取类型
		// assert(3==bNextCount || 5==bNextCount) ;
		// assert(3==bFirstCount || 5==bFirstCount) ;

		byte bNextType = GetCardType(bNextList, bNextCount, btCardSpecialData);
		byte bFirstType = GetCardType(bFirstList, bFirstCount, btCardSpecialData);

		assert (SssConstants.CT_INVALID != bNextType && SssConstants.CT_INVALID != bFirstType);
		if (SssConstants.CT_INVALID == bFirstType || SssConstants.CT_INVALID == bNextType)
			return false;

		// 头段比较
		if (true == bComperWithOther) {
			if (3 == bFirstCount) {
				// 开始对比
				if (bNextType == bFirstType) {
					switch (bFirstType) {
					case SssConstants.CT_SINGLE: // 单牌类型
					{
						// 数据验证
						// 数据验证
						assert (bNextList[0] != bFirstList[0]);
						if (bNextList[0] == bFirstList[0])
							return false;

						boolean bAllSame = true;

						for (byte i = 0; i < 3; ++i)
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								bAllSame = false;
								break;
							}

						if (true == bAllSame)
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
						else {
							for (byte i = 0; i < 3; ++i)
								if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
									return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							return false;
						}

						// return false ;

					}
					case SssConstants.CT_ONE_DOUBLE: // 对带一张
					{
						// 数据验证
						assert (bNextList[NextAnalyseData.bTwoFirst[0]] != bFirstList[FirstAnalyseData.bTwoFirst[0]]);
						if (bNextList[NextAnalyseData.bTwoFirst[0]] == bFirstList[FirstAnalyseData.bTwoFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bTwoFirst[0]])) {
							if (GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]) != GetCardLogicValue(
									bFirstList[FirstAnalyseData.bOneFirst[0]]))
								return GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]) > GetCardLogicValue(
										bFirstList[FirstAnalyseData.bOneFirst[0]]);
							else
								return GetCardColor(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardColor(
										bFirstList[FirstAnalyseData.bTwoFirst[0]]);
						} else
							return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[0]]);
					}

					case SssConstants.CT_THREE: // 三张牌型
					{
						// 数据验证
						if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]]) {
							// #ifdef _DEBUG
							//
							// AfxMessageBox("bNextList[NextAnalyseData.bThreeFirst[0]]!=bFirstList[FirstAnalyseData.bThreeFirst[0]]")
							// ;
							// #endif
						}
						assert (bNextList[NextAnalyseData.bThreeFirst[0]] != bFirstList[FirstAnalyseData.bThreeFirst[0]]);
						if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bThreeFirst[0]]))
							return GetCardColor(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardColor(
									bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较花色
						else
							return GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较数值
					}

					}

				} else
					return bNextType > bFirstType;
			} else if (5 == bFirstCount) {
				// 开始对比
				if (bNextType == bFirstType) {

					switch (bFirstType) {
					case SssConstants.CT_SINGLE: // 单牌类型
					{
						// 数据验证
						assert (bNextList[0] != bFirstList[0]);
						if (bNextList[0] == bFirstList[0])
							return false;

						boolean bAllSame = true;

						for (byte i = 0; i < 5; ++i)
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								bAllSame = false;
								break;
							}

						if (true == bAllSame)
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
						else {
							for (byte i = 0; i < 5; ++i)
								if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
									return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							return false;
						}

						// return false ;

					}
					case SssConstants.CT_ONE_DOUBLE: // 对带一张
					{
						// 数据验证
						assert (bNextList[NextAnalyseData.bTwoFirst[0]] != bFirstList[FirstAnalyseData.bTwoFirst[0]]);
						if (bNextList[NextAnalyseData.bTwoFirst[0]] == bFirstList[FirstAnalyseData.bTwoFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bTwoFirst[0]])) {
							// 对比单张
							for (byte i = 0; i < 3; ++i) {
								if (GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[i]]) != GetCardLogicValue(
										bFirstList[FirstAnalyseData.bOneFirst[i]]))
									return GetCardLogicValue(
											bNextList[NextAnalyseData.bOneFirst[i]]) > GetCardLogicValue(
													bFirstList[FirstAnalyseData.bOneFirst[i]]);
							}
							return GetCardColor(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardColor(
									bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较花色
						} else
							return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较数值
					}
					case SssConstants.CT_FIVE_TWO_DOUBLE: // 两对牌型
					{
						// 数据验证
						assert (bNextList[NextAnalyseData.bTwoFirst[0]] != bFirstList[FirstAnalyseData.bTwoFirst[0]]);
						if (bNextList[NextAnalyseData.bTwoFirst[0]] == bFirstList[FirstAnalyseData.bTwoFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bTwoFirst[0]])) {
							if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[1]]) == GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[1]])) {
								if (GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]) != GetCardLogicValue(
										bFirstList[FirstAnalyseData.bOneFirst[0]]))
									return GetCardLogicValue(
											bNextList[NextAnalyseData.bOneFirst[0]]) > GetCardLogicValue(
													bFirstList[FirstAnalyseData.bOneFirst[0]]);

								return GetCardColor(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardColor(
										bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较花色
							} else
								return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[1]]) > GetCardLogicValue(
										bFirstList[FirstAnalyseData.bTwoFirst[1]]); // 比较数值
						} else
							return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较数值
					}

					case SssConstants.CT_THREE: // 三张牌型
					{
						// 数据验证
						if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]]) {
							// #ifdef _DEBUG
							//
							// AfxMessageBox("bNextList[NextAnalyseData.bThreeFirst[0]]!=bFirstList[FirstAnalyseData.bThreeFirst[0]]")
							// ;
							// #endif
						}
						assert (bNextList[NextAnalyseData.bThreeFirst[0]] != bFirstList[FirstAnalyseData.bThreeFirst[0]]);
						if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bThreeFirst[0]]))
							return GetCardColor(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardColor(
									bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较花色
						else
							return GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较数值
					}

					case SssConstants.CT_FIVE_MIXED_FLUSH_FIRST_A: // A在前顺子
					{
						// 数据验证
						assert (bNextList[0] != bFirstList[0]);
						if (bNextList[0] == bFirstList[0])
							return false;

						if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
						else
							return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); // 比较数值

					}
					case SssConstants.CT_FIVE_MIXED_FLUSH_NO_A: // 没A杂顺
					{
						// 数据验证
						assert (bNextList[0] != bFirstList[0]);
						if (bNextList[0] == bFirstList[0])
							return false;

						if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
						else
							return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); // 比较数值
					}
					case SssConstants.CT_FIVE_MIXED_FLUSH_BACK_A: // A在后顺子
					{
						// 数据验证
						assert (bNextList[0] != bFirstList[0]);
						if (bNextList[0] == bFirstList[0])
							return false;

						if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
						else
							return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); // 比较数值

					}

					case SssConstants.CT_FIVE_FLUSH: // 同花五牌
					{
						// 数据验证
						assert (bNextList[0] != bFirstList[0]);
						if (bNextList[0] == bFirstList[0])
							return false;

						// 比较数值
						for (byte i = 0; i < 5; ++i)
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);

						// 比较花色
						return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
					}

					case SssConstants.CT_FIVE_THREE_DEOUBLE: // 三条一对
					{
						// 数据验证
						assert (bNextList[NextAnalyseData.bThreeFirst[0]] != bFirstList[FirstAnalyseData.bThreeFirst[0]]);
						if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bThreeFirst[0]]))
							return GetCardColor(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardColor(
									bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较花色
						else
							return GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较数值
					}

					case SssConstants.CT_FIVE_FOUR_ONE: // 四带一张
					{
						// 数据验证
						assert (bNextList[NextAnalyseData.bFourFirst[0]] != bFirstList[FirstAnalyseData.bFourFirst[0]]);
						if (bNextList[NextAnalyseData.bFourFirst[0]] == bFirstList[FirstAnalyseData.bFourFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bFourFirst[0]]))
							return GetCardColor(bNextList[NextAnalyseData.bFourFirst[0]]) > GetCardColor(
									bFirstList[FirstAnalyseData.bFourFirst[0]]); // 比较花色
						else
							return GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bFourFirst[0]]); // 比较数值

					}
					case SssConstants.CT_FIVE_STRAIGHT_FLUSH_NO_A: // 没A同花顺
					case SssConstants.CT_FIVE_STRAIGHT_FLUSH_FIRST_A:// A在前同花顺
					case SssConstants.CT_FIVE_STRAIGHT_FLUSH_BACK_A: // A在后同花顺
					{
						// 数据验证
						assert (bNextList[0] != bFirstList[0]);
						if (bNextList[0] == bFirstList[0])
							return false;

						// 比较数值
						for (byte i = 0; i < 5; ++i)
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);

						// 比较花色
						return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);

					}
					default:
						// #ifdef _DEBUG
						// AfxMessageBox("错误扑克类型！") ;
						// #endif
						return false;
					}

				} else {
					// 同花顺牌
					// if( bNextType==CT_FIVE_STRAIGHT_FLUSH_FIRST_A ||
					// bNextType==CT_FIVE_STRAIGHT_FLUSH)
					// {
					// if(CT_FIVE_STRAIGHT_FLUSH_FIRST_A==bFirstType ||
					// CT_FIVE_STRAIGHT_FLUSH==bFirstType)
					// {
					// if(bNextType!=bFirstType)
					// return bNextType > bFirstType ;
					//
					// //比较数值
					// for(byte i=0; i<5; ++i)
					// if(GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
					// return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]) ;
					//
					// //比较花色
					// return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]) ;
					// }
					// }
					// 顺子A-5 最小
					if (firstAConfig == 1) {
						if ((bFirstType == SssConstants.CT_FIVE_MIXED_FLUSH_NO_A
								&& bNextType == SssConstants.CT_FIVE_MIXED_FLUSH_FIRST_A)
								|| (bFirstType == SssConstants.CT_FIVE_MIXED_FLUSH_FIRST_A
										&& bNextType == SssConstants.CT_FIVE_MIXED_FLUSH_NO_A)) {
							return bFirstType > bNextType;
						}
					}
					return bNextType > bFirstType;
				}
			} else {
				if (bNextType == bFirstType) {
					switch (bFirstType) {
					case SssConstants.CT_THIRTEEN_FLUSH: {
						return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
						// return false;
					}
					case SssConstants.CT_TWELVE_KING: {
						boolean AllSame = true;
						for (int i = 0; i < 13; i++) {
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								AllSame = false;
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							}
						}
						if (AllSame) {
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
						}
						return false;
					}
					case SssConstants.CT_THREE_STRAIGHTFLUSH: {
						boolean AllSame = true;
						for (int i = 0; i < 13; i++) {
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								AllSame = false;
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							}
						}
						if (AllSame) {
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
						}
						return false;
					}
					case SssConstants.CT_THREE_BOMB: {
						assert (bNextList[NextAnalyseData.bFourFirst[0]] != bFirstList[FirstAnalyseData.bFourFirst[0]]);
						if (bNextList[NextAnalyseData.bFourFirst[0]] == bFirstList[FirstAnalyseData.bFourFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bFourFirst[0]])) {
							if (GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[1]]) == GetCardLogicValue(
									bFirstList[FirstAnalyseData.bFourFirst[1]])) {
								if (GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[2]]) == GetCardLogicValue(
										bFirstList[FirstAnalyseData.bFourFirst[2]])) {
									if (GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]) == GetCardLogicValue(
											bFirstList[FirstAnalyseData.bOneFirst[0]])) {
										return GetCardColor(bNextList[NextAnalyseData.bFourFirst[0]]) > GetCardColor(
												bFirstList[FirstAnalyseData.bFourFirst[0]]);
									} else {
										return GetCardLogicValue(
												bNextList[NextAnalyseData.bOneFirst[0]]) > GetCardLogicValue(
														bFirstList[FirstAnalyseData.bOneFirst[0]]);
									}
								} else {
									return GetCardLogicValue(
											bNextList[NextAnalyseData.bFourFirst[2]]) > GetCardLogicValue(
													bFirstList[FirstAnalyseData.bFourFirst[2]]);
								}
							} else {
								return GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[1]]) > GetCardLogicValue(
										bFirstList[FirstAnalyseData.bFourFirst[1]]);
							}
						} else
							return GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bFourFirst[0]]); // 比较数值
						// return false;
					}
					case SssConstants.CT_ALL_BIG: {
						boolean AllSame = true;
						for (int i = 0; i < 13; i++) {
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								AllSame = false;
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							}
						}
						if (AllSame) {
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
						}
						return false;
					}
					case SssConstants.CT_ALL_SMALL: {

						boolean AllSame = true;
						for (int i = 0; i < 13; i++) {
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								AllSame = false;
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							}
						}
						if (AllSame) {
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
						}
						return false;
					}
					case SssConstants.CT_SAME_COLOR: {
						boolean AllSame = true;
						for (int i = 0; i < 13; i++) {
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								AllSame = false;
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							}
						}
						if (AllSame) {
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
						}
						return false;
					}
					case SssConstants.CT_FOUR_THREESAME: {

						assert (bNextList[NextAnalyseData.bThreeFirst[0]] != bFirstList[FirstAnalyseData.bThreeFirst[0]]);
						if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bThreeFirst[0]])) {
							if (GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[1]]) == GetCardLogicValue(
									bFirstList[FirstAnalyseData.bThreeFirst[1]])) {
								if (GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[2]]) == GetCardLogicValue(
										bFirstList[FirstAnalyseData.bThreeFirst[2]])) {
									if (GetCardLogicValue(
											bNextList[NextAnalyseData.bThreeFirst[3]]) == GetCardLogicValue(
													bFirstList[FirstAnalyseData.bThreeFirst[3]])) {
										if (GetCardLogicValue(
												bNextList[NextAnalyseData.bOneFirst[0]]) == GetCardLogicValue(
														bFirstList[FirstAnalyseData.bOneFirst[0]])) {
											return GetCardColor(
													bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardColor(
															bFirstList[FirstAnalyseData.bThreeFirst[0]]);
										} else {
											return GetCardLogicValue(
													bNextList[NextAnalyseData.bOneFirst[0]]) > GetCardLogicValue(
															bFirstList[FirstAnalyseData.bOneFirst[0]]);
										}

									} else {
										return GetCardLogicValue(
												bNextList[NextAnalyseData.bThreeFirst[3]]) > GetCardLogicValue(
														bFirstList[FirstAnalyseData.bThreeFirst[3]]);
									}
								} else {
									return GetCardLogicValue(
											bNextList[NextAnalyseData.bThreeFirst[2]]) > GetCardLogicValue(
													bFirstList[FirstAnalyseData.bThreeFirst[2]]);
								}
							} else {
								return GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[1]]) > GetCardLogicValue(
										bFirstList[FirstAnalyseData.bThreeFirst[1]]);
							}
						} else
							return GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较数值
						// return false;
					}

					case SssConstants.CT_FIVEPAIR_THREE: {

						assert (bNextList[NextAnalyseData.bTwoFirst[0]] != bFirstList[FirstAnalyseData.bTwoFirst[0]]);
						if (bNextList[NextAnalyseData.bTwoFirst[0]] == bFirstList[FirstAnalyseData.bTwoFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bTwoFirst[0]])) {
							if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[1]]) == GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[1]])) {
								if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[2]]) == GetCardLogicValue(
										bFirstList[FirstAnalyseData.bTwoFirst[2]])) {
									if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[3]]) == GetCardLogicValue(
											bFirstList[FirstAnalyseData.bTwoFirst[3]])) {
										if (GetCardLogicValue(
												bNextList[NextAnalyseData.bTwoFirst[4]]) == GetCardLogicValue(
														bFirstList[FirstAnalyseData.bTwoFirst[4]])) {
											if (GetCardLogicValue(
													bNextList[NextAnalyseData.bThreeFirst[0]]) == GetCardLogicValue(
															bFirstList[FirstAnalyseData.bThreeFirst[0]])) {
												return GetCardColor(
														bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardColor(
																bFirstList[FirstAnalyseData.bTwoFirst[0]]);
											} else {
												return GetCardLogicValue(
														bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardLogicValue(
																bFirstList[FirstAnalyseData.bThreeFirst[0]]);
											}
										} else {
											return GetCardLogicValue(
													bNextList[NextAnalyseData.bTwoFirst[4]]) == GetCardLogicValue(
															bFirstList[FirstAnalyseData.bTwoFirst[4]]);
										}
									} else {
										return GetCardLogicValue(
												bNextList[NextAnalyseData.bTwoFirst[3]]) > GetCardLogicValue(
														bFirstList[FirstAnalyseData.bTwoFirst[3]]);
									}
								} else {
									return GetCardLogicValue(
											bNextList[NextAnalyseData.bTwoFirst[2]]) > GetCardLogicValue(
													bFirstList[FirstAnalyseData.bTwoFirst[2]]);
								}
							} else {
								return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[1]]) > GetCardLogicValue(
										bFirstList[FirstAnalyseData.bTwoFirst[1]]);
							}
						} else
							return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较数值
						// return false;
					}

					case SssConstants.CT_SIXPAIR: {
						assert (bNextList[NextAnalyseData.bTwoFirst[0]] != bFirstList[FirstAnalyseData.bTwoFirst[0]]);
						if (bNextList[NextAnalyseData.bTwoFirst[0]] == bFirstList[FirstAnalyseData.bTwoFirst[0]])
							return false;

						if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bTwoFirst[0]])) {
							if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[1]]) == GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[1]])) {
								if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[2]]) == GetCardLogicValue(
										bFirstList[FirstAnalyseData.bTwoFirst[2]])) {
									if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[3]]) == GetCardLogicValue(
											bFirstList[FirstAnalyseData.bTwoFirst[3]])) {
										if (GetCardLogicValue(
												bNextList[NextAnalyseData.bTwoFirst[4]]) == GetCardLogicValue(
														bFirstList[FirstAnalyseData.bTwoFirst[4]])) {
											if (GetCardLogicValue(
													bNextList[NextAnalyseData.bTwoFirst[5]]) == GetCardLogicValue(
															bFirstList[FirstAnalyseData.bTwoFirst[5]])) {
												if (GetCardLogicValue(
														bNextList[NextAnalyseData.bOneFirst[0]]) == GetCardLogicValue(
																bFirstList[FirstAnalyseData.bOneFirst[0]])) {
													return GetCardColor(
															bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardColor(
																	bFirstList[FirstAnalyseData.bTwoFirst[0]]);
												} else {
													return GetCardLogicValue(
															bNextList[NextAnalyseData.bOneFirst[0]]) > GetCardLogicValue(
																	bFirstList[FirstAnalyseData.bOneFirst[0]]);
												}
											} else {
												return GetCardLogicValue(
														bNextList[NextAnalyseData.bTwoFirst[5]]) > GetCardLogicValue(
																bFirstList[FirstAnalyseData.bTwoFirst[5]]);
											}
										} else {
											return GetCardLogicValue(
													bNextList[NextAnalyseData.bTwoFirst[4]]) == GetCardLogicValue(
															bFirstList[FirstAnalyseData.bTwoFirst[4]]);
										}
									} else {
										return GetCardLogicValue(
												bNextList[NextAnalyseData.bTwoFirst[3]]) > GetCardLogicValue(
														bFirstList[FirstAnalyseData.bTwoFirst[3]]);
									}
								} else {
									return GetCardLogicValue(
											bNextList[NextAnalyseData.bTwoFirst[2]]) > GetCardLogicValue(
													bFirstList[FirstAnalyseData.bTwoFirst[2]]);
								}
							} else {
								return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[1]]) > GetCardLogicValue(
										bFirstList[FirstAnalyseData.bTwoFirst[1]]);
							}
						} else
							return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较数值
						// return false;
					}
					case SssConstants.CT_THREE_FLUSH: {
						boolean AllSame = true;
						for (int i = 0; i < 13; i++) {
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								AllSame = false;
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							}
						}
						if (AllSame) {
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
						}
						return false;
					}
					case SssConstants.CT_THREE_STRAIGHT: {
						boolean AllSame = true;
						for (int i = 0; i < 13; i++) {
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
								AllSame = false;
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
							}
						}
						if (AllSame) {
							return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
						}
						return false;
					}
					}
				} else
					return bNextType > bFirstType;
			}
		} else {
			// 开始对比
			if (bNextType == bFirstType) {
				switch (bFirstType) {
				case SssConstants.CT_SINGLE: // 单牌类型
				{
					// 数据验证
					assert (bNextList[0] != bFirstList[0]);
					if (bNextList[0] == bFirstList[0])
						return false;

					boolean bAllSame = true;

					for (byte i = 0; i < 3; ++i)
						if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) {
							bAllSame = false;
							break;
						}

					if (true == bAllSame)
						return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
					else {
						for (byte i = 0; i < 3; ++i)
							if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
								return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
						return bNextCount < bFirstCount;
					}

					// return bNextCount < bFirstCount ;

				}
				case SssConstants.CT_ONE_DOUBLE: // 对带一张
				{
					// 数据验证
					assert (bNextList[NextAnalyseData.bTwoFirst[0]] != bFirstList[FirstAnalyseData.bTwoFirst[0]]);
					if (bNextList[NextAnalyseData.bTwoFirst[0]] == bFirstList[FirstAnalyseData.bTwoFirst[0]])
						return false;

					if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) == GetCardLogicValue(
							bFirstList[FirstAnalyseData.bTwoFirst[0]])) {
						if (GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]) != GetCardLogicValue(
								bFirstList[FirstAnalyseData.bOneFirst[0]]))
							return GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bOneFirst[0]]);

						return GetCardColor(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardColor(
								bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较花色
					} else
						return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardLogicValue(
								bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较数值

					// return bNextCount < bFirstCount ;
				}
				case SssConstants.CT_FIVE_TWO_DOUBLE: // 两对牌型
				{
					// 数据验证
					assert (bNextList[NextAnalyseData.bTwoFirst[0]] != bFirstList[FirstAnalyseData.bTwoFirst[0]]);
					if (bNextList[NextAnalyseData.bTwoFirst[0]] == bFirstList[FirstAnalyseData.bTwoFirst[0]])
						return false;

					if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) == GetCardLogicValue(
							bFirstList[FirstAnalyseData.bTwoFirst[0]])) {
						if (GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[1]]) == GetCardLogicValue(
								bFirstList[FirstAnalyseData.bTwoFirst[1]])) {
							// 对比单牌
							if (GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]) != GetCardLogicValue(
									bFirstList[FirstAnalyseData.bOneFirst[0]]))
								return GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]) > GetCardLogicValue(
										bFirstList[FirstAnalyseData.bOneFirst[0]]);

							return GetCardColor(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardColor(
									bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较花色
						} else
							return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[1]]) > GetCardLogicValue(
									bFirstList[FirstAnalyseData.bTwoFirst[1]]); // 比较数值
					} else
						return GetCardLogicValue(bNextList[NextAnalyseData.bTwoFirst[0]]) > GetCardLogicValue(
								bFirstList[FirstAnalyseData.bTwoFirst[0]]); // 比较数值
					// return bNextCount < bFirstCount ;
				}

				case SssConstants.CT_THREE: // 三张牌型
				{
					// 数据验证
					if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]]) {
						// #ifdef _DEBUG
						//
						// AfxMessageBox("bNextList[NextAnalyseData.bThreeFirst[0]]!=bFirstList[FirstAnalyseData.bThreeFirst[0]]")
						// ;
						// #endif
					}
					assert (bNextList[NextAnalyseData.bThreeFirst[0]] != bFirstList[FirstAnalyseData.bThreeFirst[0]]);
					if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]])
						return false;

					if (GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) == GetCardLogicValue(
							bFirstList[FirstAnalyseData.bThreeFirst[0]]))
						return GetCardColor(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardColor(
								bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较花色
					else
						return GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardLogicValue(
								bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较数值
					// return bNextCount < bFirstCount ;
				}

				case SssConstants.CT_FIVE_MIXED_FLUSH_FIRST_A: // A在前顺子
				{
					// 数据验证
					assert (bNextList[0] != bFirstList[0]);
					if (bNextList[0] == bFirstList[0])
						return false;

					if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
						return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
					else
						return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); // 比较数值
					// return bNextCount < bFirstCount ;
				}
				case SssConstants.CT_FIVE_MIXED_FLUSH_NO_A: // 没A杂顺
				{
					// 数据验证
					assert (bNextList[0] != bFirstList[0]);
					if (bNextList[0] == bFirstList[0])
						return false;

					if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
						return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
					else
						return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); // 比较数值
				}
				case SssConstants.CT_FIVE_MIXED_FLUSH_BACK_A: // A在后顺子
				{
					// 数据验证
					assert (bNextList[0] != bFirstList[0]);
					if (bNextList[0] == bFirstList[0])
						return false;

					if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
						return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); // 比较花色
					else
						return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); // 比较数值

				}

				case SssConstants.CT_FIVE_FLUSH: // 同花五牌
				{
					// 数据验证
					assert (bNextList[0] != bFirstList[0]);
					if (bNextList[0] == bFirstList[0])
						return false;

					// 比较数值
					for (byte i = 0; i < 5; ++i)
						if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
							return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);

					// 比较花色
					return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
				}

				case SssConstants.CT_FIVE_THREE_DEOUBLE: // 三条一对
				{
					// 数据验证
					assert (bNextList[NextAnalyseData.bThreeFirst[0]] != bFirstList[FirstAnalyseData.bThreeFirst[0]]);
					if (bNextList[NextAnalyseData.bThreeFirst[0]] == bFirstList[FirstAnalyseData.bThreeFirst[0]])
						return false;

					if (GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) == GetCardLogicValue(
							bFirstList[FirstAnalyseData.bThreeFirst[0]]))
						return GetCardColor(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardColor(
								bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较花色
					else
						return GetCardLogicValue(bNextList[NextAnalyseData.bThreeFirst[0]]) > GetCardLogicValue(
								bFirstList[FirstAnalyseData.bThreeFirst[0]]); // 比较数值
				}

				case SssConstants.CT_FIVE_FOUR_ONE: // 四带一张
				{
					// 数据验证
					assert (bNextList[NextAnalyseData.bFourFirst[0]] != bFirstList[FirstAnalyseData.bFourFirst[0]]);
					if (bNextList[NextAnalyseData.bFourFirst[0]] == bFirstList[FirstAnalyseData.bFourFirst[0]])
						return false;

					if (GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[0]]) == GetCardLogicValue(
							bFirstList[FirstAnalyseData.bFourFirst[0]]))
						return GetCardColor(bNextList[NextAnalyseData.bFourFirst[0]]) > GetCardColor(
								bFirstList[FirstAnalyseData.bFourFirst[0]]); // 比较花色
					else
						return GetCardLogicValue(bNextList[NextAnalyseData.bFourFirst[0]]) > GetCardLogicValue(
								bFirstList[FirstAnalyseData.bFourFirst[0]]); // 比较数值

				}

				case SssConstants.CT_FIVE_STRAIGHT_FLUSH_NO_A: // 没A同花顺
				case SssConstants.CT_FIVE_STRAIGHT_FLUSH_FIRST_A:// A在前同花顺
				case SssConstants.CT_FIVE_STRAIGHT_FLUSH_BACK_A: // A在后同花顺
				{
					// 数据验证
					assert (bNextList[0] != bFirstList[0]);
					if (bNextList[0] == bFirstList[0])
						return false;

					// 比较数值
					for (byte i = 0; i < 5; ++i)
						if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
							return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);

					// 比较花色
					return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);

				}
				default:
					// #ifdef _DEBUG
					// AfxMessageBox("错误扑克类型！") ;
					// #endif
					return false;
				}

			} else {
				// 同花顺牌
				// if( bNextType==CT_FIVE_STRAIGHT_FLUSH_FIRST_A ||
				// bNextType==CT_FIVE_STRAIGHT_FLUSH)
				// {
				// if(CT_FIVE_STRAIGHT_FLUSH_FIRST_A==bFirstType ||
				// CT_FIVE_STRAIGHT_FLUSH==bFirstType)
				// {
				// if(bNextType!=bFirstType)
				// return bNextType > bFirstType ;
				//
				// //比较数值
				// for(byte i=0; i<5; ++i)
				// if(GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
				// return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]) ;
				//
				// //比较花色
				// return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]) ;
				//
				// }
				// }
				// 顺子A-5 最小
				if (firstAConfig == 1) {
					if ((bFirstType == SssConstants.CT_FIVE_MIXED_FLUSH_NO_A
							&& bNextType == SssConstants.CT_FIVE_MIXED_FLUSH_FIRST_A)
							|| (bFirstType == SssConstants.CT_FIVE_MIXED_FLUSH_FIRST_A
									&& bNextType == SssConstants.CT_FIVE_MIXED_FLUSH_NO_A)) {
						return bFirstType > bNextType;
					}
				}
				return bNextType > bFirstType;
			}
		}
		return false;
	}

	public static void main(String[] args) {
		SssAlgorithm sssAlgorithm = new SssAlgorithm();
		boolean ret = sssAlgorithm.CompareCard(new byte[] { 0x01, 0x02, 0x03 }, new byte[] { 0x07, 0x08, 0x09 },
				(byte) 3, (byte) 3, false,(byte)2);
		System.out.println(ret);
	}

}
